package org.javaboy.vhr.service;

import org.javaboy.vhr.mapper.AdjustSalaryMapper;
import org.javaboy.vhr.model.AdjustSalary;
import org.javaboy.vhr.model.Employee;
import org.javaboy.vhr.vo.AdjustSalaryVo;
import org.javaboy.vhr.vo.RespPageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Author: cheng
 */
@Service
public class AdjustSalaryService {
    @Autowired
    AdjustSalaryMapper adjustSalaryMapper;


    public RespPageBean getAdjSalByPage(Integer page, Integer size, AdjustSalary adjustSalary, Date[] beginDateScope) {
        if (page != null && size != null) {
            page = (page - 1) * size;
        }
        List<AdjustSalaryVo> data = adjustSalaryMapper.getAdjSalByPage(page,size,adjustSalary,beginDateScope);
        Long total = adjustSalaryMapper.getTotal(adjustSalary, beginDateScope);
        RespPageBean bean = new RespPageBean();
        bean.setData(data);
        bean.setTotal(total);
        return bean;
    }

    public Integer add(AdjustSalary adjustSalary){
        return adjustSalaryMapper.insertSelective(adjustSalary);
    }

    public Integer delete(int id){
        return adjustSalaryMapper.deleteByPrimaryKey(id);
    }

    public Integer update(AdjustSalary adjustSalary){
        return adjustSalaryMapper.updateByPrimaryKey(adjustSalary);
    }


}
